/*
 * @Author: lg
 * @Date: 2023-09-16 17:37:32
 * @LastEditors: lg
 * @LastEditTime: 2024-09-12 14:13:59
 * @Description:
 * @FilePath: \ssii-user-bk\src\request\index.ts
 */
import { HttpRequest } from '@hb/hb-services';
import { ElMessage } from 'element-plus';
const TIME_OUT = 30 * 1000;
const { VITE_APP_API } = (import.meta as any).env;
const baseUrl = VITE_APP_API;
const options = {
  baseURL: baseUrl,
  withCredentials: false,
  timeout: TIME_OUT,
  headers: {
    'Access-Control-Allow-Origin': '*'
  },
  //自定义配置
  customParams: {},
  messageCallback: (message: string, type: any = 'error', response: any) => {
    try {
      ElMessage.error(message);
    } catch (error) {
      console.log(error);
    }
  },
  addHeaderFn: () => {
    return {
      token: ''
    };
  }
};
const { instance: ajax } = new HttpRequest(options);

export { ajax, baseUrl };
